package com.example.onlineeducation.data.constant

import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.StringDef
import com.example.onlineeducation.R

/**
 * SimpleDes:
 * Creator: Sindi
 * Date: 2022-01-17
 * UseDes:学习
 */
object StudyConstants {

    /*
    * 学习进度
    * */
    const val NOT_STUDIED = "0"//未学习
    const val WAIT_STUDY = "1"//待学习
    const val STUDIED = "2"//已学习

    @StringDef(NOT_STUDIED, WAIT_STUDY, STUDIED)
    @kotlin.annotation.Retention(AnnotationRetention.SOURCE)
    annotation class Progress

    @DrawableRes
    fun showProgressIcon(@Progress str: String?): Int {
        return when (str) {
            STUDIED -> R.drawable.label_bg_green
            WAIT_STUDY -> R.drawable.label_bg_yellow
            else -> R.drawable.label_bg_red
        }
    }

    fun showProgressText(@Progress str: String?): String {
        return when (str) {
            STUDIED -> "已学习"
            WAIT_STUDY -> "待学习"
            else -> "未学习"
        }
    }

    @ColorRes
    fun showProgressTextColor(@Progress str: String?): Int {
        return when (str) {
            STUDIED -> R.color.state_green
            WAIT_STUDY -> R.color.state_yellow
            else -> R.color.state_red
        }
    }


    /*
    * 学习素材状态
    * */
    const val NOT_STARTED = "not_started"//未开始
    const val IN_PROGRESS = "in_progress"//进行中
    const val IS_OVER = "is_over"//已结束

    @StringDef(NOT_STARTED, IN_PROGRESS, IS_OVER)
    @kotlin.annotation.Retention(AnnotationRetention.SOURCE)
    annotation class MaterialStatus

    fun showMaterialStatusIcon(@MaterialStatus str: String): Int {
        return when (str) {
            NOT_STARTED -> R.drawable.label_bg_red
            IN_PROGRESS -> R.drawable.label_bg_yellow
            else -> R.drawable.label_bg_green
        }
    }


    /*
    * 学习结果
    * */
    const val NOT_STANDARD = "0"//未达标
    const val REACHED_STANDARD = "1"//已达标

    @StringDef(NOT_STANDARD, REACHED_STANDARD)
    @kotlin.annotation.Retention(AnnotationRetention.SOURCE)
    annotation class Result

    @DrawableRes
    fun showStudyResultIcon(@Result str: String): Int {
        return when (str) {
            REACHED_STANDARD -> R.drawable.label_bg_green
            else -> R.drawable.label_bg_red
        }
    }

    fun showStudyResultText(@Result str: String): String {
        return when (str) {
            REACHED_STANDARD -> "已达标"
            else -> "未达标"
        }
    }


    @ColorRes
    fun showStudyResultTextColor(@Result str: String): Int {
        return when (str) {
            REACHED_STANDARD -> R.color.state_green
            else -> R.color.state_red
        }
    }

}